package com.butuh.uang.tuh.ang.util;

import android.content.Context;
import android.os.Bundle;

import com.facebook.appevents.AppEventsConstants;
import com.facebook.appevents.AppEventsLogger;
import com.google.firebase.analytics.FirebaseAnalytics;

import static com.facebook.FacebookSdk.getApplicationContext;

public class OnClickLogFaceFireUtil {

    private static OnClickLogFaceFireUtil instance = null;

    private static AppEventsLogger logger;

    private static FirebaseAnalytics mFirebaseAnalytics;

    private OnClickLogFaceFireUtil() {
    }

    public static OnClickLogFaceFireUtil getInstance(Context context) {
        if (instance == null) {
            synchronized (OnClickLogFaceFireUtil.class) {
                if (instance == null) {
                    instance = new OnClickLogFaceFireUtil();
                }
            }
        }
        if (null == logger) {
            logger = AppEventsLogger.newLogger(getApplicationContext());
        }
        if (null == mFirebaseAnalytics) {
            mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
        }
        return instance;
    }


    public void setAnalytics(String name, String message, int bianhao) {
        Bundle bundle = new Bundle();
        bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
        bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, message);
        bundle.putString(FirebaseAnalytics.Param.ITEM_ID, String.valueOf(bianhao));
        mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
        logger.logEvent(AppEventsConstants.EVENT_NAME_CONTACT, bundle);
    }


}
